package com.nxmu.service.impl;

import com.nxmu.dao.UserDao;
import com.nxmu.entity.User;
import com.nxmu.service.UserService;

public class UserServiceImpl implements UserService {

//    @Autowired
    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    /**
     * 登陆
     * @param user
     * @return
     */
    public User login(User user){
        return userDao.login(user.getUserId(),user.getPassword(),user.getRole());
    }

    @Override
    public void register(User user) {
        userDao.saveOrUpdate(user);
    }

    @Override
    public boolean checkUserExist(User user) {
        return userDao.getByUsername(user.getUsername()).size() > 0 ? true : false;
    }

}
